<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>安伴后台管理系统-修改学校信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .layui-form-label {
            width: 150px;
        }
        .layui-form-item .layui-input-inline {
            width: 260px;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div style="width: 100%;height: 20px;"></div>
        <div class="layui-row">
            <form class="layui-form" id="data-form">
                {{.xsrfdata}}
                <input type="hidden" name="id" value="{{.record.Id}}">
                <div class="layui-form-item">
                    <label class="layui-form-label">学校</label>
                    <div class="layui-form-mid layui-word-aux">{{.record.Name}}</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>上午上课时间
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="morning_time" name="morning_time" value="{{.record.MorningTime}}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux"></div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>下午上课时间
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="afternoon_time" name="afternoon_time" value="{{.record.AfternoonTime}}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux"></div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">每学期学费</label>
                    <div class="layui-input-inline">
                        <input type="text" id="tuition" name="tuition" value="{{.record.Tuition}}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">元</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">短信通知</label>
                    <div class="layui-input-block">
                        <input type="checkbox" lay-filter="mobile-msg" name="is_use_mobile_msg" value="1" {{if eq .record.IsUseMobileMsg 1}}checked{{end}} lay-skin="switch" lay-text="使用|不使用">
                    </div>
                    <div class="layui-form-mid layui-word-aux">短信通知包括未按时到校预警，未按时离校预警，体温异常预警，滞留校车预警，会议通知</div>
                </div>
                <div class="layui-form-item {{if eq .record.IsUseMobileMsg 0}}layui-hide{{end}}" id="mobile-msg-price-form">
                    <label class="layui-form-label">短信通知费用</label>
                    <div class="layui-input-inline">
                        <input type="text" id="mobile_msg_price" name="mobile_msg_price" value="{{.record.MobileMsgPrice}}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">元</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">门禁通知</label>
                    <div class="layui-input-block">
                        <input type="checkbox" lay-filter="access-control" name="is_use_access_control" value="1" {{if eq .record.IsUseAccessControl 1}}checked{{end}} lay-skin="switch" lay-text="使用|不使用">
                    </div>
                </div>
                <div class="layui-form-item {{if eq .record.IsUseAccessControl 0}}layui-hide{{end}}" id="access-control-price-form">
                    <label class="layui-form-label">门禁通知费用</label>
                    <div class="layui-input-inline">
                        <input type="text" id="access_control_price" name="access_control_price" value="{{.record.AccessControlPrice}}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">元</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">校车通知</label>
                    <div class="layui-input-block">
                        <input type="checkbox" lay-filter="school-bus" name="is_use_school_bus" value="1" {{if eq .record.IsUseSchoolBus 1}}checked{{end}} lay-skin="switch" lay-text="使用|不使用">
                    </div>
                </div>
                <div class="layui-form-item {{if eq .record.IsUseSchoolBus 0}}layui-hide{{end}}" id="school-bus-price-form">
                    <label class="layui-form-label">校车通知费用</label>
                    <div class="layui-input-inline">
                        <input type="text" id="school_bus_price" name="school_bus_price" value="{{.record.SchoolBusPrice}}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">元</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">体温通知</label>
                    <div class="layui-input-block">
                        <input type="checkbox" lay-filter="temp" name="is_use_temp" value="1" {{if eq .record.IsUseTemp 1}}checked{{end}} lay-skin="switch" lay-text="使用|不使用">
                    </div>
                </div>
                <div class="layui-form-item {{if eq .record.IsUseTemp 0}}layui-hide{{end}}" id="temp-price-form">
                    <label class="layui-form-label">体温通知费用</label>
                    <div class="layui-input-inline">
                        <input type="text" id="temp_price" name="temp_price" value="{{.record.TempPrice}}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">元</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">作业通知</label>
                    <div class="layui-input-block">
                        <input type="checkbox" lay-filter="homework" name="is_use_homework" value="1" {{if eq .record.IsUseHomework 1}}checked{{end}} lay-skin="switch" lay-text="使用|不使用">
                    </div>
                </div>
                <div class="layui-form-item {{if eq .record.IsUseHomework 0}}layui-hide{{end}}" id="homework-price-form">
                    <label class="layui-form-label">作业通知费用</label>
                    <div class="layui-input-inline">
                        <input type="text" id="homework_price" name="homework_price" value="{{.record.HomeworkPrice}}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">元</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">会议通知</label>
                    <div class="layui-input-block">
                        <input type="checkbox" lay-filter="meeting" name="is_use_meeting" value="1" {{if eq .record.IsUseMeeting 1}}checked{{end}} lay-skin="switch" lay-text="使用|不使用">
                    </div>
                </div>
                <div class="layui-form-item {{if eq .record.IsUseMeeting 0}}layui-hide{{end}}" id="meeting-price-form">
                    <label class="layui-form-label">会议通知费用</label>
                    <div class="layui-input-inline">
                        <input type="text" id="meeting_price" name="meeting_price" value="{{.record.MeetingPrice}}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">元</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">成绩通知</label>
                    <div class="layui-input-block">
                        <input type="checkbox" lay-filter="grade" name="is_use_grade" value="1" {{if eq .record.IsUseGrade 1}}checked{{end}} lay-skin="switch" lay-text="使用|不使用">
                    </div>
                </div>
                <div class="layui-form-item {{if eq .record.IsUseGrade 0}}layui-hide{{end}}" id="grade-price-form">
                    <label class="layui-form-label">成绩通知费用</label>
                    <div class="layui-input-inline">
                        <input type="text" id="grade_price" name="grade_price" value="{{.record.GradePrice}}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">元</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">每周课程安排通知</label>
                    <div class="layui-input-block">
                        <input type="checkbox" lay-filter="course" name="is_use_course" value="1" {{if eq .record.IsUseCourse 1}}checked{{end}} lay-skin="switch" lay-text="使用|不使用">
                    </div>
                </div>
                <div class="layui-form-item {{if eq .record.IsUseCourse 0}}layui-hide{{end}}" id="course-price-form">
                    <label class="layui-form-label">每周课程安排通知费用</label>
                    <div class="layui-input-inline">
                        <input type="text" id="course_price" name="course_price" value="{{.record.CoursePrice}}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">元</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <button class="layui-btn" lay-filter="do-submit" lay-submit="">修改</button>
                </div>
                <div style="width: 100%;height: 300px;"></div>
            </form>
        </div>
    </div>
</div>
<script>
    layui.use(['laydate', 'form', 'layer'],
        function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer,
                laydate = layui.laydate,
                canSubmit = true;

            laydate.render({
                elem: '#morning_time',
                type: 'time',
                range: true //或 range: '~' 来自定义分割字符
            });
            laydate.render({
                elem: '#afternoon_time',
                type: 'time',
                range: true //或 range: '~' 来自定义分割字符
            });

            form.on("switch(mobile-msg)", function (data) {
                var curObj = $('#mobile-msg-price-form');
                if (data.elem.checked) {
                    curObj.removeClass('layui-hide');
                } else {
                    curObj.addClass('layui-hide');
                }
            });
            form.on("switch(access-control)", function (data) {
                var curObj = $('#access-control-price-form');
                if (data.elem.checked) {
                    curObj.removeClass('layui-hide');
                } else {
                    curObj.addClass('layui-hide');
                }
            });
            form.on("switch(school-bus)", function (data) {
                var curObj = $('#school-bus-price-form');
                if (data.elem.checked) {
                    curObj.removeClass('layui-hide');
                } else {
                    curObj.addClass('layui-hide');
                }
            });
            form.on("switch(temp)", function (data) {
                var curObj = $('#temp-price-form');
                if (data.elem.checked) {
                    curObj.removeClass('layui-hide');
                } else {
                    curObj.addClass('layui-hide');
                }
            });
            form.on("switch(homework)", function (data) {
                var curObj = $('#homework-price-form');
                if (data.elem.checked) {
                    curObj.removeClass('layui-hide');
                } else {
                    curObj.addClass('layui-hide');
                }
            });
            form.on("switch(meeting)", function (data) {
                var curObj = $('#meeting-price-form');
                if (data.elem.checked) {
                    curObj.removeClass('layui-hide');
                } else {
                    curObj.addClass('layui-hide');
                }
            });
            form.on("switch(grade)", function (data) {
                var curObj = $('#grade-price-form');
                if (data.elem.checked) {
                    curObj.removeClass('layui-hide');
                } else {
                    curObj.addClass('layui-hide');
                }
            });
            form.on("switch(course)", function (data) {
                var curObj = $('#course-price-form');
                if (data.elem.checked) {
                    curObj.removeClass('layui-hide');
                } else {
                    curObj.addClass('layui-hide');
                }
            });

            //监听提交
            form.on('submit(do-submit)',
                function (data) {

                    if ($("#morning_time").val().length <= 0) {
                        layer.msg("请选择上午上课时间", {icon: 2});
                        return false;
                    }
                    if ($("#afternoon_time").val().length <= 0) {
                        layer.msg("请选择下午上课时间", {icon: 2});
                        return false;
                    }

                    if (!canSubmit) return false;
                    var loadIndex = layer.load();
                    canSubmit = false;

                    $.ajax({
                        url: '{{urlfor "admin.SchoolController.DoEditInfo"}}',
                        type: "POST",
                        data: $("#data-form").serialize(),
                        dataType: "json",
                        success: function (res) {

                            layer.close(loadIndex);
                            canSubmit = true;

                            if (res.status != 1) {
                                layer.msg(res.msg, {icon: 2});
                                return false;
                            }

                            layer.alert(res.msg, {icon: 6}, function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });

                        }
                    });

                    return false;

                });

        });
</script>
</body>

</html>
